# conding:utf-8
import  unittest,requests,HTMLTestRunner
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
def allStartTest():
    #待执行用例的目录
    case_dir='C:/Users/feng\Desktop\python01\my_unittest_jiekou/test_fengfan_interface'
    #构造测试集合
    suite=unittest.TestSuite()
    #获取到一个list集合
    discover = unittest.defaultTestLoader.discover(case_dir,pattern="test*.py",top_level_dir=None)
    print(discover)

    for test_suite in discover:
        for test_case in test_suite:
            print(test_case)
            suite.addTests(test_case)
    return discover
if __name__=="__main__":
    #返回实例
    report_path = "C:\\Users\\feng\\Desktop\\python01\\my_unittest_jiekou\\reports"
    report_set = open(report_path+'result.html', 'wb')
    runner = HTMLTestRunner.HTMLTestRunner(stream=report_set,
                                           title=u'自动化测试报告',
                                           description=u'用例执行情况：')

    runner.run(allStartTest())
    report_set.close()
